import { Observable } from 'rxjs';
import { ProcessStatusPipe } from './../common-util/process-status.pipe';
import { PeriodicTask, PeriodicTaskParam, ProcessStatus } from './../model/task';
import { RequestService } from './request.service';
import { Injectable } from '@angular/core';
import { CommonApi } from './commonApi';

@Injectable()
export class PeriodTaskApiService extends CommonApi<PeriodicTaskParam>{

  constructor(
    request: RequestService
  ) {
    super(request, '/periodic');
  }

  public setTaskCurrentStatus(taskId: number, status: ProcessStatus): Observable<PeriodicTask> {
   const url = this.baseUrl +  '/updateProcessStatus';
   const submitData  = new FormData();
   submitData.append('id', taskId.toPrecision());
   submitData.append('status', status.toPrecision());
   return this.baseRequest.post(url, submitData);
  }
}
